<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cn.school.util.StringKit"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@page import="cn.school.service.*,cn.school.dao.*,cn.school.entity.*,java.util.*" %>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生信息</title>
<script type="text/javascript" src="js/jquery-3.2.0.js"></script>
</head>
<body>
<%@include file="newcheckLogin.jsp" %>
<%-- <div>
 <%
   Object o=session.getAttribute("USER_LOGIN");
   if(o==null){
	   out.print("<script>alert('你丫的是翻窗户进来的？');location.replace('login.jsp');</script>");
	   return;
   }
 %>
 <h1>欢迎你，<%=o%>, <a href="logout.jsp">退出</a></h1>
</div> --%>
<%-- <p>
 <%
 String name=request.getParameter("studentname");
 %>
 您刚才注册的姓名是<%=name%>
</p> --%>
<%
String sname=StringKit.converNull(request.getParameter("sname"));
String telephone=StringKit.converNull(request.getParameter("telephone"));
String qq=StringKit.converNull(request.getParameter("qq"));
String enterdatestart=StringKit.converNull(request.getParameter("enterdatestart"));
Date enterdatestart1=StringKit.toDate(request.getParameter("enterdatestart"));
/* SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd"); */

Service service=new Service();
int pageno=1;
try{
	 pageno=Integer.parseInt(request.getParameter("pageno"));
}catch(Exception e){}

List<Student> list=service.searchLimitByMohu(pageno, 10,sname,telephone,qq,enterdatestart1);
int total=service.searchTotal(sname, telephone,qq,enterdatestart1);
out.print(total);
int pageTotal=total/10+(total%10==0?0:1);//总页数
%>
<p>
<form method="get" action="newStudent.jsp">
 <input type="search" name="sname" value="<%=sname%>" placeholder="用户名"/>
 <input type="search" name="telephone" value="<%=telephone%>" placeholder="手机号"/> 
 <input type="search" name="qq" value="<%=qq%>" placeholder="QQ号"/> 
 <input type="search" name="enterdatestart" value="<%=enterdatestart%>" placeholder="起始时间"/> 
 <input type="submit" value="search"/>
 </form>
</p>
<a href="student2.jsp">增加新生</a>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>学号</td><td>姓名</td><td>性别</td><td>电话</td><td>QQ号</td><td>微信</td><td>年级编号</td>
<td>入学日期</td>
<td>来自哪里</td><td>出生日期</td><td>地址</td><td>密码</td><td>照片</td><td>操作</td>
</tr>
<%
 for(Student s:list){
%>
 <tr>
  <td><%=s.getStuno() %></td><td><%=s.getSname() %></td> <td><%=s.getSex() %></td><td><%=s.getTelephone() %></td>
	<td><%=s.getQq() %></td><td><%=s.getWechat() %></td><td><%=s.getGradeid() %></td>
	<td><%=s.getEnterdate() %></td>
	<td><%=s.getFromcity() %></td>
	<td><%=s.getBirthday()
		
%></td><td><%=s.getAddress() %></td>
	<td><%=s.getPass() %></td>
	<td><%=s.getIdcardpic() %></td>
  <td>
  	<a onclick="return window.confirm('真的要删除？')" href="deleteStudent.jsp?stuno=<%=s.getStuno()%>">删除</a>
 	&nbsp;
 	<a  href="updateStudent.jsp?stuno=<%=s.getStuno()%>">修改</a>
  </td>
 </tr>
<%} %>
</table>
<p align="center">
 <a href="newStudent.jsp?pageno=1&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>">首页</a>
<%
  if(pageno>1){    
%>
 <a href="newStudent.jsp?pageno=<%=pageno-1%>&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>">上一页</a>
 <%} %>
 <input type="number" min="1" name="go" style="width:30px" value="<%=pageno%>"/>/<%=pageTotal%>
 <%
  if(pageTotal>pageno){
 %>
 <a href="newStudent.jsp?pageno=<%=pageno+1%>&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>">下一页</a>
 <%} %>
 <a href="newStudent.jsp?pageno=<%=pageTotal%>&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>">末页</a>
</p>
</body>
<script>
$(function(){
	 $("input[name=go]").keydown(function(event){
		
		 if(event.keyCode==13)//回车
		 {
			 if(this.value==""||isNaN(this.value)){
				 return false;
			 } 
			 window.location="newStudent.jsp?pageno="+"&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>";

		 }
	 }).blur(function(){
		 if(this.value==""||isNaN(this.value)){
			 return false;
		 } 
		 window.location="newStudent.jsp?pageno="+$(this).val()+"&sname=<%=sname%>&telephone=<%=telephone%>&qq=<%=qq%>&enterdatestart=<%=enterdatestart%>";
	 });
});
</script>
</html>